<?php 
	$ssFilter = $this->arrParam['ssFilter'];
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');
	
	//Lấy thông số trang hiện tại
	$url = Zend_Controller_Front::getInstance()->getRequest()->getPathInfo();
	
	$lblUsername 	= $this->cmsLinkSort($this->translate('Username'),'u.user_name',$ssFilter,
										$this->imgUrl . '/icon',$action_link);
	
	$lblStatus		= $this->cmsLinkSort($this->translate('Status'),'u.status',$ssFilter,
										$this->imgUrl . '/icon',$action_link);
	
	$lblOrder 		= $this->cmsLinkSort($this->translate('Order'),'u.order',$ssFilter,
										$this->imgUrl . '/icon',$action_link);
										
	$lblEmail		= $this->cmsLinkSort($this->translate('Email'),'u.email',$ssFilter,
										$this->imgUrl . '/icon',$action_link);			

	$lblRegisterDate= $this->cmsLinkSort($this->translate('Registed'),'u.register_date',$ssFilter,
										$this->imgUrl . '/icon',$action_link);
										
	$lblGroup 		= $this->cmsLinkSort($this->translate('Group'),'group_name',$ssFilter,
										$this->imgUrl . '/icon',$action_link);																	

	$lblID 		= $this->cmsLinkSort('ID','u.id',$ssFilter,
										$this->imgUrl . '/icon',$action_link);
										
	$options = $this->slbGroup;
	$linktblGroup = $this->baseUrl($this->currentController . '/filter/type/group');
	$tblGroup = $this->formSelect('groupId',$ssFilter['groupId'],array('onchange'=>"OnSubmitForm('" . $linktblGroup . "')"),$options);
	$selectGroup = 'Group : ' . $tblGroup ;	
	
	$ssFilter = $this->arrParam['ssFilter'];
	
	if($ssFilter['col'] != 'g.group_name'){		
		$linkOder =  $this->baseUrl($this->currentController . '/filter/type/order/col/g.group_name/by/DESC');
		$iconSort = $this->imgUrl . '/icon/arrow_down.png';
	}else{
		if($ssFilter['order'] == 'DESC'){
			$by = 'ASC';
			$iconSort = $this->imgUrl . '/icon/arrow_down.png';
		}else{
			$by = 'DESC';
			$iconSort = $this->imgUrl . '/icon/arrow_up.png';
		}
		
		$linkOder =  $this->baseUrl($this->currentController . 
									'/filter/type/order/col/g.group_name/by/' . $by);
	}
	
	//CREATE SEARCH AREA
	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort'));
	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch = $this->formButton('search-now',$this->translate('Search'),
									array('onclick'=>"OnSubmitForm('" . $linkSearch . "')"));
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');							
	$btnResetSearch = $this->formButton('clear-keywords',$this->translate('Clear'),
									array('onclick'=>"OnSubmitForm('" . $linkResetSearch . "')"));	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;																	
?>
<form name="appForm" method="post" action="">
						<!--Gắn thông số hiện tại vào form hidden-->
						<?php echo $this->formHidden('_url',$url);?>

                        <?php echo $this->render('toolbar.php')?>
                        <div class="clr"></div>
                        <?php //echo $this->render('sublink.php')?>

                        <!-- BEGIN: CONTENT -->
                        <div id="element-box">
                            <div class="t">
                                <div class="t">
                                    <div class="t"></div>
                                </div>
                            </div>
                            <div class="m">
                                <!-- BEGIN: ELEMENT BOX -->
								<div id="filters">
									<div style="float: left">
										<?php echo $strSearch;?>
									</div>
									<div style="float: right">
										<?php echo $selectGroup;?>
									</div>
								</div>	

                                <!-- Area 4: In du lieu lay tu database -->
                                <table class="adminlist">
                                    <thead>
                                        <tr>
                                            <th width="43" >
                                            	<input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()">
                                           	</th>
                                            <th><?php echo $lblUsername ;  ?></th>
                                            <th width="89"><?php echo $lblStatus ;  ?></th>
                                            <th width="86"><?php echo $lblOrder;?></th>	
                                            <th width="83"><?php echo $lblEmail ;  ?></th>
                                            <th width="86"><?php echo $lblRegisterDate ;  ?></th>
                                            <th width="86"><?php echo $lblGroup ;  ?></th>
                                            <th width="90"><?php echo $this->translate('Control')?></th>
                                            <th width="34"><?php echo $lblID ;  ?></th>
                                        </tr>
                                    </thead>
									<?php 
										foreach($this->Items as $key => $val){
											$id 			= $val['id'];
											$user_name 	= $val['user_name'];
											$email 	= $val['email'];
											$status 		= $val['status'];
											$register_date  = $val['register_date'];
											$group_name = $this->formSelect('group_id['.$id.']',$val['group_id'],NULL,$options);
											if($status == 1){	
												$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id);											
												//$status = $this->cmsIconButton('Active', $this->imgUrl . '/icon/active.png',$linkStatus);
												$status = $this->cmsAjaxButton('ajax-active-item', 'Active', 'Inactive *'. $user_name . '*', $linkStatus, $id);
											}else{
												$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id);
												$status = $this->cmsAjaxButton('ajax-inactive-item', 'Inactive', 'Active *'. $user_name . '*', $linkStatus, $id);
											}
											
											$group_acp 		= $val['group_acp'];
											if($group_acp == 1){												
												$group_acp = $this->cmsIconButton('Access', $this->imgUrl . '/icon/active.png');
											}else{												
												$group_acp = $this->cmsIconButton('No access', $this->imgUrl . '/icon/inactive.png');
											}
											
											$members 		= $val['members'];
											$order			= $this->formText('order['.$id.']',$val['order'],array('class'=>'order'));
											
											$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id);											
											$btnInfo		= $this->cmsIconButton('View Item',$this->imgUrl . '/icon_info.png',$linkInfo);
											
											$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id);
											$btnEdit		= $this->cmsIconButton('Edit Item',$this->imgUrl . '/icon_edit.png',$linkEdit);
											
											$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id);
											$btnDelete =  $this->cmsAjaxButton('ajax-delete-item', 'Delete Item', 'Delete *'. $user_name . '*', $linkDelete, $id);
										
											$strIconButton	= $btnInfo . ' ' . $btnEdit . ' ' . $btnDelete;
											
											$cid			= $this->formCheckbox('cid[]',$val['id']);
									?>
                                    <tr class="even">						
                                        <td align="center"><?php echo $cid;?></td>
                                        <td align="left"><?php echo $user_name;?></td>
                                        <td align="center"><?php echo $status;?></td>
                                       	<td align="center"><?php echo $order;?></td>
                                        <td align="left"><?php echo $email;?></td>
                                        <td align="center"><?php echo $register_date;?></td>
                                        <td align="center"><?php echo $group_name;?></td>
                                        <td align="center"><?php echo $strIconButton;?></td>
                                        <td align="center"><?php echo $id;?></td>
                                    </tr>
                                    <?php 
										}
                                    ?>
                                    <!-- BEGIN: PAGINATION (FOOT) -->
                                    <tfoot>
                                        <tr>
                                            <td colspan="9">
                                                <div class="container">
                                                    <div class="pagination">
                                                        <?php 
                                                        	$currentUrl = $this->baseUrl($this->currentController . '/index');
                                                        	echo $this->paginationControl($this->panigator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl));
                                                        ?>
                                                        <div class="limit"></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>					
                                    </tfoot>				<!-- END: PAGINATION (FOOT) -->
                                </table>
                                <!-- Area 4: In du lieu lay tu database - End -->

                                <!-- END: ELEMENT BOX -->	
                              <div class="clr"></div>
                            </div>
                            <div class="b">
                                <div class="b">
                                    <div class="b"></div>
                                </div>
                            </div>
                        </div>
                        <!-- END: 	CONTENT -->
                    </form>